package com.remenote.remenoteback.entity.vo;

import com.remenote.remenoteback.entity.doo.NoteDo;
import com.remenote.remenoteback.entity.doo.NotebookDo;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @BelongsProject: remenote-back
 * @BelongsPackage: com.remenote.remenoteback.entity.vo
 * @Author: 23392
 * @CreateTime: 2024-03-16  17:32
 * @Description: TODO
 * @Version: 1.0
 */
@Getter
@Setter
@Accessors(chain = true)
public class NotebookVo {
    private Integer notebookId;
    public String notebookName;
    public String description;

    public static List<NotebookVo> fromNotebookDoList(List<NotebookDo> notebookDoList) {
        List<NotebookVo> notebookVos = new ArrayList<>();
        for (NotebookDo notebookDo : notebookDoList) {
            notebookVos.add(
                    new NotebookVo()
                            .setNotebookName(notebookDo.getNotebook())
                            .setNotebookId(notebookDo.getNotebookId())
                            .setDescription(notebookDo.getDescription())
                            .setNotebookId(notebookDo.getId())
            );
        }
        return notebookVos;
    }
//    public static List<NotebookVo> fromNoteDoList(List<NoteDo> noteList) {
//        Map<String,NotebookVo> notebookMap = new HashMap<>();
//        for (NoteDo noteDo : noteList) {
//            String notebookName = noteDo.getNotebook();
//            NotebookVo notebookVo = notebookMap.get(notebookName);
//            if (notebookVo == null) {
//                notebookVo = new NotebookVo().setNotebookName(notebookName);
//                notebookVo.setNoteList(new ArrayList<>());
//                notebookMap.put(notebookName, notebookVo);
//            }
//            notebookVo.getNoteList().add(NoteVo.fromNoteDo(noteDo));
//        }
//        return new ArrayList<>(notebookMap.values());
//    }
}
